package com.ruoyi.transaction.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.transaction.domain.TTransaction;
import com.ruoyi.transaction.service.ITTransactionService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 成交记录列表Controller
 * 
 * @author ruoyi
 * @date 2025-09-10
 */
@RestController
@RequestMapping("/transaction")
public class TTransactionController extends BaseController
{
    @Autowired
    private ITTransactionService tTransactionService;

    /**
     * 查询成交记录列表列表
     */
    @RequiresPermissions("transaction:transaction:list")
    @GetMapping("/list")
    public TableDataInfo list(TTransaction tTransaction)
    {
        startPage();
        List<TTransaction> list = tTransactionService.selectTTransactionList(tTransaction);
        return getDataTable(list);
    }

    /**
     * 导出成交记录列表列表
     */
    @RequiresPermissions("transaction:transaction:export")
    @Log(title = "成交记录列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TTransaction tTransaction)
    {
        List<TTransaction> list = tTransactionService.selectTTransactionList(tTransaction);
        ExcelUtil<TTransaction> util = new ExcelUtil<TTransaction>(TTransaction.class);
        util.exportExcel(response, list, "成交记录列表数据");
    }

    /**
     * 获取成交记录列表详细信息
     */
    @RequiresPermissions("transaction:transaction:query")
    @GetMapping(value = "/{transactionId}")
    public AjaxResult getInfo(@PathVariable("transactionId") Long transactionId)
    {
        return success(tTransactionService.selectTTransactionByTransactionId(transactionId));
    }

    /**
     * 新增成交记录列表
     */
    @RequiresPermissions("transaction:transaction:add")
    @Log(title = "成交记录列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTransaction tTransaction)
    {
        return toAjax(tTransactionService.insertTTransaction(tTransaction));
    }

    /**
     * 修改成交记录列表
     */
    @RequiresPermissions("transaction:transaction:edit")
    @Log(title = "成交记录列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTransaction tTransaction)
    {
        return toAjax(tTransactionService.updateTTransaction(tTransaction));
    }

    /**
     * 删除成交记录列表
     */
    @RequiresPermissions("transaction:transaction:remove")
    @Log(title = "成交记录列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{transactionIds}")
    public AjaxResult remove(@PathVariable Long[] transactionIds)
    {
        return toAjax(tTransactionService.deleteTTransactionByTransactionIds(transactionIds));
    }
}
